
$(function(){
	$("#files").on("change",function (e) {
        $("#fileList").html("");
        
        var folders = [];
        /* for (var i = 0; i < arr.length; i++) {
            if (array .indexOf(arr[i]) === -1) {
                array .push(arr[i])
            }
        }*/
        
        $.each(this.files, function (k,v) {
            //console.log(v.type+"="+v.webkitRelativePath);
        	var filePath = v.webkitRelativePath;
        	var splits = filePath.split("/");
        	var parentFolder = splits[splits.length-2];
        	
        	if (folders.indexOf(parentFolder) === -1) {
        		folders.push(parentFolder);
        		$("#fileList").append( '<div class="item">' +
                        '<span class="info">/' + parentFolder + '</span>' +
                        '</div>' );
            }
        	
        }); //each end
    });
	
	/*var errorCode =$("#errorCode").val();
	if(errorCode == '1'){
		layer.msg("批量导入成功");
	}else if(errorCode =='0'){
		layer.msg("批量导入失败,非预期结果");
	}else if(errorCode == '-1'){
		layer.msg("批量导入失败");
	}*/
	
	var errorCode =$("#errorCode").val();
	var msg = $("#msg").val();
	if (errorCode != null && errorCode != '') {
		if (errorCode == "200") {
			layer.msg("批量导入成功");
		} else {
			layer.alert(msg);
		}
		
	}
	
});

function validatation(){ 
	var file = document.getElementById('files'); 
	
	if(file.value == ""){
			alert("请选择要上传的文件夹！");
			return false;
	 } else {
		//加载效果
   		layer.load(1, {
   	        shade: [0.1,'#fff']}); //0.1透明度的白色背景
   		return true; 
   	} 
}

//form提交
function submitUpload(){
	$("#uploadForm").submit();
}




